<!-- BEGIN PAGE CONTAINER-->
<div class="container-fluid">
    <!-- BEGIN PAGE HEADER-->
    <div class="row-fluid">
        <div class="span12">
            <!-- BEGIN PAGE TITLE & BREADCRUMB-->
            <h3 class="page-title">
                Quản lý đơn hàng
            </h3>
            <ul class="breadcrumb">
                <li>
                    <i class="icon-home"></i>
                    <a href="index.html">Trang chủ</a>
                    <i class="icon-angle-right"></i>
                </li>
                <li><a href="#">Quản lý đơn hàng</a></li>
            </ul>
            <!-- END PAGE TITLE & BREADCRUMB-->
        </div>
    </div>
        <!-- END PAGE HEADER-->
    <!-- BEGIN PAGE CONTENT-->
    <div class="row-fluid">
        <div class="span12">
            <!-- BEGIN EXAMPLE TABLE PORTLET-->
            <div class="portlet box light-grey">
                <div class="portlet-title">
                    <h4><i class="icon-th-list"></i>Chi tiết đơn hàng</h4>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                </div>
				<div class="all-product">
					<div class="contact">
						<h4>Transaction ID: <strong><?php echo $order->transaction_id?></strong></h4>
						<h4>Payment Method: <strong><?php echo $order->paymentMethod->description?></strong></h4>
						<table class="table table-bordered">
							<tr>
								<th>No.</th>
								<th>Picture</th>
								<th>Item name</th>
								<th>Quantity</th>
								<th>Unit</th>
								<th>Total</th>
							</tr>
							<?php
							$i = 1;
							$totalPrice = 0;
							$price = 0;
							$weightTotal = 0;
							foreach ($products as $position => $product) {
								if (@$model = Products::model()->findByPk($product['product_id'])) {
									$variations = '';
									if (isset($product['frame-included'])) {
										// Check frame included
										$variations = 1;
									}
									$weightTotal += $model['weight'];
									?>
									<tr>
										<td align="center" valign="top" width="6%"><?php echo $i;?></td>
										<td align="center" width="10%"><img src="<?php echo Yii::app()->request->baseUrl; ?>/data/upload/products/<?php echo isset($model->shopImages[0]) ? $model->shopImages[0]->filename : 'no_image.jpg'?>"
																			width="50" height="50"></td>
										<td><?php echo $model['title'] ?></td>
										<td align="center" valign="top" width="15%"><input readonly="true" style="width:60px" name=""
																						   placeholder="<?php echo $product['amount']?>" type="text"></td>
										<td align="left" valign="top" width="15%">
											<h3 rel="<?php echo Shop::priceFormat($model->getPrice(@$variations)); ?>" class="<?php echo 'price_'.$position;?>">$<?php echo Shop::priceFormat($model->getPrice(@$variations)); ?></h3>
										</td>
				
										<td width="15%" align="center" valign="middle">
											<h3 rel="">$<?php 
												$price = $model->getPrice(@$variations) * intval($product['amount']);
												echo Shop::priceFormat($price) ?>
											</h3>
										</td>
									</tr>
									
								<?php
									$totalPrice += $price;
								} $i++;
							}?>
							<tr>
								<td colspan="5"><b>Shipping Price</b></td>
								<?php 
									$pracelPrice = new PracelPrice();
									$shippingPriceTotal = $pracelPrice->getShippingPrice($country, $weightTotal)
								?>
								<td align="center"><h3>$<?php echo Shop::priceFormat($shippingPriceTotal);?></h3></td>
							</tr>
							<tr>
								<td colspan="5"><h2>Total Payment</h2></td>
								<td align="center"><h2>$<?php echo Shop::priceFormat($totalPrice + $shippingPriceTotal);?></h2></td>
							</tr>
						</table>
						<h4>Billing Address</h4>
						<table class="table table-bordered" width="60%">
							<tr>
								<td>First Name</td>
								<td><?php echo $order->billingAddress->firstname;?></td>
							</tr>
							<tr>
								<td>Last Name</td>
								<td><?php echo $order->billingAddress->lastname;?></td>
							</tr>
							<tr>
								<td>Country</td>
								<td><?php 
			        				$country = Country::model()->findbyPk($order->billingAddress->country);
									echo $country->name;
								?></td>
							</tr>
							<tr>
								<td>Street</td>
								<td><?php echo $order->billingAddress->street;?></td>
							</tr>
							<tr>
								<td>City</td>
								<td><?php echo $order->billingAddress->city;?></td>
							</tr>
							<tr>
								<td>State</td>
								<td><?php echo $order->billingAddress->state;?></td>
							</tr>
							<tr>
								<td>Zip Code</td>
								<td><?php echo $order->billingAddress->zipcode;?></td>
							</tr>
							<tr>
								<td>Email</td>
								<td><?php echo $order->billingAddress->email;?></td>
							</tr>
							<tr>
								<td>Phone</td>
								<td><?php echo $order->billingAddress->phone;?></td>
							</tr>
						</table>
					</div>
				</div>
			</div>
		</div>
		<br />
        <button type="button" onclick="window.location='/admin/order/admin'" class="btn">Back</button>
	</div>
</div>